﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TimeManager : MonoBehaviour {

    public float m_SlowdownFactor = .05f;
    public float m_SlowdownLength = 2;

    private void Update()
    {
        float tryTimeScale = Time.timeScale + (1 / m_SlowdownLength) * Time.unscaledDeltaTime;
        if(tryTimeScale>=0 && tryTimeScale<=1)
        {
            Time.timeScale = tryTimeScale;
        }
    }

    public void DoSlowmotion()
    {
        Time.timeScale = m_SlowdownFactor;
        Time.fixedDeltaTime = Time.timeScale * 0.02f;
    }
}
